package Solutions
func garbageCollection(garbage []string, travel []int) int {
    var p1,p2,p3=0,0,0;
    var ans=0
    for i:=0;i<len(garbage);i++{
        for j:=0;j<len(garbage[i]);j++{
            if garbage[i][j]=='M'{
                p1=i
            }else if garbage[i][j]=='P'{
                p2=i
            }else{
                p3=i
            }
        }
        ans+=len(garbage[i])
    }
    for i:=0;i<p1;i++{
        ans+=travel[i]
    }
    for i:=0;i<p2;i++{
        ans+=travel[i]
    }
    for i:=0;i<p3;i++{
        ans+=travel[i]
    }
    return ans
}